package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectFeedback;
import com.ruoyi.system.service.IProjectFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目问题反馈Controller
 *
 * @author ruoyi
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/system/projectFeedback")
public class ProjectFeedbackController extends BaseController
{
    @Autowired
    private IProjectFeedbackService projectFeedbackService;

    /**
     * 查询项目问题反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectFeedback projectFeedback)
    {
        startPage();
        List<ProjectFeedback> list = projectFeedbackService.selectProjectFeedbackList(projectFeedback);
        return getDataTable(list);
    }

    /**
     * 导出项目问题反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:export')")
    @Log(title = "项目问题反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectFeedback projectFeedback)
    {
        List<ProjectFeedback> list = projectFeedbackService.selectProjectFeedbackList(projectFeedback);
        ExcelUtil<ProjectFeedback> util = new ExcelUtil<ProjectFeedback>(ProjectFeedback.class);
        util.exportExcel(response, list, "项目问题反馈数据");
    }

    /**
     * 获取项目问题反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:query')")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return success(projectFeedbackService.selectProjectFeedbackByFeedbackId(feedbackId));
    }

    /**
     * 新增项目问题反馈
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:add')")
    @Log(title = "项目问题反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectFeedback projectFeedback)
    {
        return toAjax(projectFeedbackService.insertProjectFeedback(projectFeedback));
    }

    /**
     * 修改项目问题反馈
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:edit')")
    @Log(title = "项目问题反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectFeedback projectFeedback)
    {
        return toAjax(projectFeedbackService.updateProjectFeedback(projectFeedback));
    }

    /**
     * 删除项目问题反馈
     */
    @PreAuthorize("@ss.hasPermi('system:projectFeedback:remove')")
    @Log(title = "项目问题反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(projectFeedbackService.deleteProjectFeedbackByFeedbackIds(feedbackIds));
    }
}
